﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Shop.Core.App_Start
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            #region 后台登陆路由
            routes.MapRoute(
              name: "AdminLogin",
              url: "AdminLogin",
              defaults: new { controller = "Hui", action = "login" },
              namespaces: new[] { "Shop.Backstage.Controllers" }
           );
            #endregion

            #region 后台管理路由
            routes.MapRoute(
               name: "UpdatePage",
               url: "Page/UpdatePage-{HID}",
               defaults: new { controller = "Page", action = "UpdatePage" },
               constraints: new { HID = @"\d+"},
               namespaces: new[] { "Shop.Page.Controllers" }
            );
            routes.MapRoute(
               name: "Category",
               url: "Home/Category-{CID}-{SCID}",
               defaults: new { controller = "Home", action = "Category" },
               constraints: new { CID = @"\d+", SCID = @"\d+" },
               namespaces: new[] { "Shop.Home.Controllers" }
            );
            routes.MapRoute(
              name: "Product",
              url: "Home/WaresProduct-{WID}",
              defaults: new { controller = "Home", action = "WaresProduct" },
              constraints: new { WID = @"\d+" },
              namespaces: new[] { "Shop.Home.Controllers" }
            );

            routes.MapRoute(
                name: "UpdateWares",
                url: "Wares/UpdateWares-{WID}",
                defaults: new { controller = "Wares", action = "UpdateWares" },
                constraints: new { WID = @"\d+" },
                namespaces: new[] { "Shop.Wares.Controllers" }
            );
            routes.MapRoute(
                name: "SonWaresCategory",
                url: "Wares/SonWaresCategory-{CID}",
                defaults: new { controller = "Wares", action = "SonWaresCategory"},
                constraints: new { CID = @"\d+" },
                namespaces: new[] { "Shop.Wares.Controllers" }
            );
            #endregion
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "HomePage", id = UrlParameter.Optional }
            );
        }
    }
}
